package com.fankui.crowd.mvc.config;

import com.fankui.crowd.entity.Admin;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * ClassName SecurityAdmin
 * Description TODO
 * Date 2023/8/3 18:34
 *
 * @Author 范奎
 * @Since JDK 11
 */
public class SecurityAdmin extends User {
    private static final long serialVersionUID = 1L;

    private Admin originalAdmin;

    public SecurityAdmin(Admin originalAdmin, Collection<? extends GrantedAuthority> authorities) {
        // 1 调用父类构造器
        super(originalAdmin.getLoginAcct(), originalAdmin.getUserPswd(), authorities);
        // 2 给本类的this.originalAdmin赋值
        this.originalAdmin = originalAdmin;
        // 3 将原始Admin对象中的密码擦除
        this.originalAdmin.setUserPswd(null);
    }

    public Admin getOriginalAdmin() {
        return originalAdmin;
    }
}
